package com.zr.plant.mapper;

import com.zr.plant.pojo.LegalPersonResultVo;
import com.zr.plant.pojo.Legalperson;
import com.zr.plant.pojo.PlantClass;
import com.zr.plant.pojo.PlantSelectVo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * Created by 86151 on 2019/6/14.
 */
@Mapper
public interface PlantMapper {
    @Select("select * from legalpersonplant where code = #{code}")
    List<PlantClass> queryByCode(String code);

    @Select("select * from legalperson where code = #{code}")
    List<Legalperson> queryLegalPersonByCode(String code);

//    @Insert("insert into legalpersonplant (remark,code,legalPersonCode,status,createTime,createName,updateTime," +
//            "updateName) values (#{legalPlantDec},#{legalPlantCode},#{legalPersonCode},#{enabled},#{createTime},#{createName},#{updateTime},#{updateName}) ")
//    int addPlant(PlantClass plantClass);

    @Update("update legalpersonplant set remark= #{legalPlantDec},status=#{enabled} where code = #{legalPlantCode}")
    int updatePlant(PlantClass plantClass);

    @Update("update legalpersonplant set status=#{enabled} where id = #{id}")
    int updateStatus(PlantClass plantClass);

    @Select("select le.id,le.remark,le.`status`,le.legalPersonCode,ln.`name` legalPersonName " +
            "from legalpersonplant le left join legalperson ln on le.legalPersonCode =  ln.code where le.id = #{id}")
    PlantClass queryPlantById(Integer id);


    @Select("select * from legalperson where uid = #{uid}")
    List<Legalperson> queryLegalPersonByUid(Integer uid);

    List<PlantClass> queryPage(PlantSelectVo plantSelectVo);
    int queryCount(PlantSelectVo plantSelectVo);

    @Select("select name legalPersonName,code legalPersonCode from legalperson")
    List<LegalPersonResultVo> queryLegalPersons();

    List<String> queryByCodes(List<String> codeList);

    List<String> queryByNames(List<String> nameList);

    int addPlant(List<PlantClass> plantClassList);

    List<PlantClass> queryBySelectVo(PlantSelectVo plantSelectVo);

    /*@Select("select * from planclass where name = #{name}")
    List<PlantClass> queryByName(String name);

    @Insert("insert into planclass (name,legalPlantCode,content,status,createTime,createName,updateTime," +
            "updateName) values (#{name},#{legalPlantCode},#{content},#{status},#{createTime},#{createName},#{updateTime},#{updateName}) ")
    int addPlant(PlantClass plantClass);

    @Select("select * from planclass where id=#{id}")
    PlantClass queryById(Integer id);

  */
}
